star_on="%(star_on)s";
star_off="%(star_off)s";

function on_link_mouse_down(e) 
{
    
    url = e.target.href;
    if (e.which == 1) {
        // left button, open page in the same tab
        // do nothing, rely on usual click
    } else if (e.which == 2) {
        // middle button
        // open in new tab
        url = "newtab://" + url
        document.location.href = url;
    } else if (e.which == 3) {
        // right button
    }
}

// rating, onmouseover
function rmor(e, mark) 
{
    for (i=1; i<=mark; i++) {
        el = document.getElementById("rating_"+i);
        el.src = star_on;
    }
}

// rating, onmouseout
function rmou(e, mark, orig_state)
{
    var len = orig_state.length;
    for (i=1; i<=len; i++) {
        var c = orig_state.substr(i-1, 1);
        var src;
        if ("0"==c) {
            src = star_off;
        } else {
            src = star_on;
        }
        el = document.getElementById("rating_"+i);
        el.src = src;
    }
}

function omd(e)
{
    // right mouse button has been clicked
    if (2 == e.button) {
        id = e.target.id;
        if ("" != id && -1 != id.search(/^([a-z]+):(.*)$/)) {
            t = RegExp.$1;
            v = RegExp.$2;
            url = ""
            if ("book" == t) {
                // "book" link has been clicked
                url = "rclick://doesnmatter?type=book&id="+v;
            }
            if ("" != url) {
                document.location.href = url;
            }
        }
    }
}
